package com.luoye.lj.platform.dao.impl;

import com.luoye.lj.platform.dao.IAuthServiceDao;
import com.luoye.lj.platform.dao.mapper.IAuthServiceMapper;
import com.luoye.lj.platform.model.domain.AuthInfo;
import com.luoye.lj.platform.model.domain.AuthInfoDetailCollection;
import com.luoye.lj.platform.model.domain.AuthInfoSearchCondition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by wei on 2015/11/30.
 */
@Service
public class AuthServiceDaoImpl implements IAuthServiceDao {
    @Autowired
    IAuthServiceMapper mapper;

    @Override
    public AuthInfo addAuth(AuthInfo aif) {
        if (mapper.addAuth(aif) > 0) {
            return aif;
        }else return null;

    }

    @Override
    public boolean delAuth(long authId) {
        int count = mapper.delAuth(authId);
        if(count >= 1 ){
            return true;
        }else return false;
    }

    @Override
    public AuthInfo modifyAuth(AuthInfo aif) {
        int count = mapper.modifyAuth(aif);
        if(count >= 1){
            return aif;
        }else return null;
    }

    @Override
    public List<AuthInfo> getAll() {
        List<AuthInfo> list = mapper.getAll();
        return list;
    }

    @Override
    public AuthInfo getById(long id) {

        return mapper.getById(id);
    }

    @Override
    public AuthInfoDetailCollection search(AuthInfoSearchCondition authsearch) {
        List<AuthInfo> list = mapper.search(authsearch);
        AuthInfoDetailCollection aisc = new AuthInfoDetailCollection();
        aisc.setTotalCount(mapper.talCount(authsearch));
        aisc.setDetailList(list);
        return aisc;
    }
    public AuthInfo getByname(String authname){
        return mapper.getByname(authname);
    }
    public int getDelmark(long id){
        return mapper.getDelmark(id);
    }
    public boolean recover(long id){
        if(mapper.recover(id) > 0){
            return true;
        }
        return false;

    }
}
